import en from '../assets/lang/en.json';
import zh from '../assets/lang/zh.json';
import {initReactI18next} from 'react-i18next';
import i18n from 'i18next';

const resources = {
  en: {
    translation: en,
  },
  zh: {
    translation: zh,
  },
};
i18n.use(initReactI18next).init({
  lng: 'zh',
  resources: resources,
});
export default i18n;
export const setI18nLang = lang => {
  i18n.changeLanguage(lang, (err, t) => {
    if (err) {
      return console.log('something went wrong loading', err);
    }
    // t('key'); // -> same as i18next.t
  });
};
export const langConfig = [
  {
    name: '简体中文',
    value: 'zh',
  },
  {
    name: 'English',
    value: 'en',
  },
];
